import { getInfo,setInfo,removeInfo } from "@/utils/storage"

export default {
    namespaced: true,
    state () {
      return {
        userInfo: getInfo()
      }
    },
    mutations: {
        setUserInfo (state, obj) {
            state.userInfo = obj
            setInfo(obj)
          },
          resetUserInfo(state) {
            state.userInfo = {
              userId: ''
            }
            removeInfo()
          }
    },
    actions: {
      updateUserInfo({ commit }, obj) {
        commit('setUserInfo', obj);
      },
      logout({ commit }) {
        commit('resetUserInfo');
      }
    }
  }